//
//  EPCNavgitionController.swift
//  Weibo
//
//  Created by 吴林峰 on 01/04/2017.
//  Copyright © 2017 MyGit. All rights reserved.
//

import UIKit

class EPCNavgitionController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.navigationBar.isHidden = true
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        
        if  self.viewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
            
            var backTitle = "返回"
            if self.viewControllers.count == 1 {
                backTitle = self.viewControllers.first?.title ?? "返回"
            }
            
            if let vc = viewController as? EPCBaseTableController {
                vc.navItem.leftBarButtonItem = UIBarButtonItem.init(title:backTitle, target: self, action: #selector(popToParent), isBack: true)
            }
        }
        
        
        super.pushViewController(viewController, animated: animated)
    }
    
    @objc private func popToParent() {
        popViewController(animated: true)
    }
}
